home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2006 September / SAN CD 9-2006 CD-ROM 16.iso / pc / Software / Network Telescope Control / NTC-Setup.Exe / Source / ntc_client_moon.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2006-03-24  |  3.7 KB  |  199 lines

  1. unit ntc_client_moon;
  2. {
  3.     Copyright (C) 2004 - 2006 Andrew Sprott
  4.  
  5.     http://astronomy.crysania.co.uk
  6.     astro@trefach.co.uk
  7.  
  8.     This program is free software; you can redistribute it and/or
  9.     modify it under the terms of the GNU General Public License
  10.     as published by the Free Software Foundation; either version 2
  11.     of the License, or (at your option) any later version.
  12.  
  13.     This program is distributed in the hope that it will be useful,
  14.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16.     GNU General Public License for more details.
  17.  
  18.     You should have received a copy of the GNU General Public License
  19.     along with this program; if not, write to the Free Software
  20.     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. }
  22.  
  23. interface
  24.  
  25. uses
  26.     Windows,
  27.     Messages,
  28.     SysUtils,
  29.     Variants,
  30.     Classes,
  31.     Graphics,
  32.     Controls,
  33.     Forms,
  34.     Dialogs,
  35.     ExtCtrls,
  36.     StdCtrls,
  37.     inifiles,
  38.  
  39.     ntc_client_form;
  40.     
  41. type
  42.   Tscope_moon = class(TForm)
  43.     moon_panel: TPanel;
  44.     moon_group: TGroupBox;
  45.     moon_shape: TShape;
  46.         { form functions }
  47.         procedure formcreate(
  48.             Sender:TObject);
  49.  
  50.         procedure form_close_query(
  51.                     Sender: TObject;
  52.             var CanClose: Boolean);
  53.  
  54.         { configuration }
  55.         procedure load_settings;
  56.  
  57.         procedure save_settings;
  58.  
  59.         { events }
  60.         procedure FormShow(
  61.             Sender:TObject);
  62.  
  63.         procedure adjust;
  64.  
  65.         procedure check_activate(
  66.             Sender: TObject);
  67.  
  68.     private
  69.         { Private declarations }
  70.     public
  71.         { Public declarations }
  72.         { configuration }
  73.         dimensions:dimensions_record;
  74.  
  75.         { events }
  76.         procedure check_visible_and_show_hide(
  77.             sender:tobject);
  78.             
  79.         procedure hide_form;
  80.         procedure show_form;
  81.     end;
  82.  
  83. var
  84.     scope_moon: Tscope_moon;
  85.  
  86. implementation
  87.  
  88. {$R *.dfm}
  89.  
  90.     { -------------
  91.         form controls
  92.         ------------- }
  93.  
  94. procedure tscope_moon.formcreate(
  95.     Sender:TObject);
  96. begin
  97.     load_settings;
  98. end;
  99.  
  100. procedure tscope_moon.form_close_query(
  101.             Sender: TObject;
  102.     var CanClose: Boolean);
  103. begin
  104.     canclose:=false;
  105.     visible:=false;
  106.     with dimensions do
  107.         begin
  108.             form_top:=top;
  109.             form_left:=left;
  110.         end;
  111. end;
  112.  
  113.     { -------------
  114.         configuration
  115.         ------------- }
  116.  
  117. procedure tscope_moon.load_settings;
  118. begin
  119.     ini_file:=tinifile.create(application_path+'client.ini');
  120.     with ini_file do
  121.         begin
  122.             { form }
  123.             scope.get_dimensions(scope_moon,@dimensions,'moon',ini_file);
  124.             left:=dimensions.form_left;
  125.             top:=dimensions.form_top;
  126.             visible:=readbool('moon','visible',false);
  127.         end;
  128.     ini_file.free;
  129. end;
  130.  
  131. procedure tscope_moon.save_settings;
  132. begin
  133.     with ini_file do
  134.         begin
  135.             { form }
  136.             scope.find_vdu(scope_moon,@dimensions);
  137.             scope.write_dimensions(@dimensions,left,top,'moon',ini_file);
  138.             writebool('moon','visible',visible);
  139.         end;
  140. end;
  141.  
  142.     { ------
  143.         events
  144.         ------ }
  145.  
  146. procedure tscope_moon.FormShow(
  147.     Sender:TObject);
  148. begin
  149.     with dimensions do
  150.         begin
  151.             top:=form_top;
  152.             left:=form_left;
  153.         end;
  154. end;
  155.  
  156. procedure tscope_moon.adjust;
  157. begin
  158.     with dimensions do
  159.         begin
  160.             form_top:=trunc(form_top/last_screen_height*current_height);
  161.             form_left:=trunc(form_left/last_screen_width*current_width);
  162.         end;
  163.     if visible then
  164.         show;
  165. end;
  166.  
  167. procedure tscope_moon.check_visible_and_show_hide(
  168.     sender:tobject);
  169. begin
  170.     if visible then
  171.         hide_form
  172.     else
  173.         show_form;
  174.     scope.show_hide(sender,visible);
  175. end;
  176.  
  177. procedure tscope_moon.hide_form;
  178. begin
  179.     with dimensions do
  180.         begin
  181.             form_top:=top;
  182.             form_left:=left;
  183.         end;
  184.     Visible:=false;
  185. end;
  186.  
  187. procedure tscope_moon.show_form;
  188. begin
  189.     Visible:=true;
  190. end;
  191.  
  192. procedure tscope_moon.check_activate(
  193.     Sender: TObject);
  194. begin
  195.     scope.form_activate(scope_moon,@dimensions);
  196. end;
  197.  
  198. end.
  199.